<?php

namespace App\Cms\Controller;

class Search extends Base {

    public function index() {
        
        $this->current_nav_id = 'search';
        
        $this->keywords = $keywords = urldecode($this->request->get('keywords'));
        
        $this->title = '检索';
        
        if(!$keywords) {
            return;
        }
        
        $this->title = "{$keywords} - 检索";
        
        $count = Cms()->Article()->countList($keywords);

        /* 分页 */
        $this->page_size = 10;
        $pager = $this->_createPager($count, array('keywords' => $keywords));
        $length = $pager['length'];
        $start = $pager['offset'];
        $this->assign('pager', $pager);

        $rows = Cms()->Article()->searchList($keywords, $start, $length);
        
        $this->rows = $rows;
    }
    
}
